#include "State.h"
#include "StateFactory.h"

int EatState::Enter(Object* pObject)
{
	cout << pObject->GetName() << " begin eat" << endl;
	return 0;
}

int EatState::Exec(Object* pObject)
{
	pObject->AddHp(1);
	if (pObject->GetHp() >= 10)
	{
		pObject->ChangeState(SF.GetStateByType(STATE_TYPE_WORK));
	}
	return 0;
}

int WorkState::Enter(Object* pObject)
{
	cout << pObject->GetName() << " begin work" << endl;
	return 0;
}

int WorkState::Exec(Object* pObject)
{
	pObject->CostHp(1);
	if (pObject->GetHp() < 5)
	{
		pObject->ChangeState(SF.GetStateByType(STATE_TYPE_EAT));
	}
	return 0;
}

int HomeState::Enter(Object* pObject)
{
	cout << pObject->GetName() << " begin home" << endl;
	return 0;
}

int HomeState::Exec(Object* pObject)
{
	pObject->AddHp(1);
	if (pObject->GetHp() > 10)
	{
		pObject->ChangeState(SF.GetStateByType(STATE_TYPE_WORK));
	}
	return 0;
}
